package com.service.impl;

import java.io.IOException;
import java.util.Properties;
import org.springframework.stereotype.Service;
import com.entity.User;
import com.service.interfaces.UserService;
import com.utils.UtilsProperties;

@Service("userService")
public class UserServiceImpl implements UserService{
	
	public User login(User user){
		Properties users = null;
		try {
			users = UtilsProperties.loadPropertiesByFile("c:/appConfigFile/user");
		} catch (IOException e) {
			e.printStackTrace();
		}
		if(users.containsKey(user.getUsername())){
			String password_db = ((String) users.get(user.getUsername())).split(",")[0];
			if(user.getPassword().equals(password_db)){
				return user;
			}
		}else{
			System.out.println("not exist!");
		}

		return null;
	}
	
	public void test(){
		System.out.println("userService test method...");
	}
}
